package com.neu.niuyuchao.dao;

import com.neu.commons.Dao.BaseDao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MgrApproveDaoImpl extends BaseDao {
    public List<Map<String,Object>> findStuApprove(int pageCount){
       List<Map<String,Object>> list=new ArrayList<>();
       String sql="select ceil(count(stu_no)/?)a from v_mgr_approve";
       list=BaseDaoQuery(sql,pageCount);
        System.out.println(list);

//        System.out.println(sql);
//        System.out.println(list);

        return list;
    }
    public List<Map<String,Object>> findPage(int pageIndex,int pageNum){
        List<Map<String,Object>> list=new ArrayList<>();
        int end=pageIndex*pageNum;
        int begin=(pageIndex-1)*pageNum;
        String sql="  select * " +
                " from " +
                " (select a.*, rownum  ro from" +
                " ( select * from v_mgr_approve where status='0' )a where rownum<=?)b" +
                " where ro>?";
        list=BaseDaoQuery(sql,end,begin);
//        System.out.println(list);
        return list;
    }

    public int updateApplyStatus(String appro_id){
        int row=0;
        String sql="update t_approve set status='2' where appro_id=?";
//        System.out.println(sql);
        row=BaseDaoUpdate(sql,appro_id);
//        System.out.println(row);
        return row;
    }
    public int updateApplyStatusTwo(String appro_id2){
        int row=0;
        String sql="update t_approve set status='1' where appro_id=?";
//        System.out.println(sql);
        row=BaseDaoUpdate(sql,appro_id2);
//        System.out.println(row);
        return row;
    }
    public  List<Map<String, Object>> findStuDorId(Object...params){
        List<Map<String, Object>> list=new ArrayList<>();
        String sql="  select dor_id from t_dor_info "
                +" where  dor_build=?  and  dor_no=?";
            System.out.println(sql);
        list=BaseDaoQuery(sql,params);
            System.out.println(list);
        return list;
    }
    public int updateStuDor(Object...params){
        int row=0;
        String sql=" update t_stu_info set dor_id=? where stu_id=?";
        row=BaseDaoUpdate(sql,params);
        return row;
    }


    public List<Map<String,Object>> checkhistory() {
        List<Map<String, Object>> list = new ArrayList<>();
        BaseDao d = new BaseDao();
        String sql = "select * from v_sphistory";
        list = d.BaseDaoQuery(sql);
        return list;
    }
    public List<Map<String,Object>> checkStuApply(String stu_id){
        List<Map<String,Object>> list=new ArrayList<>();
        String sql="select go_build,go_dor,status from v_mgr_approve where stu_id=?";
        System.out.println(sql);
        list=BaseDaoQuery(sql,stu_id);
        System.out.println(list);
        return list;
    }
}
